package com.test2015.Swing.jtreetable.ext;

import com.test2015.Swing.jtreetable.AbstractTreeTableModel;

public class MyTreeTableModel extends AbstractTreeTableModel{
	private MyTreeNode tree = null;
	
	public MyTreeTableModel(MyTreeNode root) {
		super(root);
		tree = root;
	}

	@Override
	public int getColumnCount() {
		return tree.getColsName().length;
	}

	@Override
	public String getColumnName(int column) {
		return tree.getColsName()[column];
	}

	@Override
	public Object getValueAt(Object node, int column) {
		MyTreeNode tmpnode = (MyTreeNode)node;
		return tmpnode.getValueByCol(column);
	}

	@Override
	public Object getChild(Object obj, int i) {
		MyTreeNode tmpnode = (MyTreeNode)obj;
		return tmpnode.getChilds()[i];
	}

	@Override
	public int getChildCount(Object obj) {
		MyTreeNode tmpnode = (MyTreeNode)obj;
		return tmpnode.getChildCount();
	}

	@Override
	public Class getColumnClass(int column) {
		return tree.getColsType()[column];
	}

	public MyTreeNode getTree() {
		return tree;
	}

	public void setTree(MyTreeNode tree) {
		this.tree = tree;
	}
	
}
